package com.small.sentinel;

import com.small.sentinel.node.Node;
import com.small.sentinel.slotchain.ResourceWrapper;
import com.small.sentinel.slots.block.BlockException;

/**
 * 入口许可
 */
public abstract class Entry {

    /**
     * 当前节点
     */
    private Node curNode;

    /**
     * 资源包装器
     */
    protected final ResourceWrapper resourceWrapper;

    /**
     * 创建时间
     */
    private final long createTimestamp;

    /**
     * 完成时间
     */
    private long completeTimestamp;

    /**
     * 错误
     */
    private Throwable error;

    /**
     * 校验异常
     */
    private BlockException blockError;

    public abstract Node getLastNode();

    public Entry(ResourceWrapper resourceWrapper) {
        this.resourceWrapper = resourceWrapper;
        this.createTimestamp = System.currentTimeMillis();
    }

    public Node getCurNode() {
        return curNode;
    }

    public long getCreateTimestamp() {
        return createTimestamp;
    }

    public void setCurNode(Node curNode) {
        this.curNode = curNode;
    }

    public Throwable getError() {
        return error;
    }

    public void setError(Throwable error) {
        this.error = error;
    }

    public BlockException getBlockError() {
        return blockError;
    }

    public void setBlockError(BlockException blockError) {
        this.blockError = blockError;
    }

    public long getCompleteTimestamp() {
        return completeTimestamp;
    }

    public void setCompleteTimestamp(long completeTimestamp) {
        this.completeTimestamp = completeTimestamp;
    }
}
